package com.jms.listener;

import com.alibaba.fastjson.JSON;
import com.jms.entity.MaterialOrder;
import com.jms.rabbitmq.constant.Topic;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.stereotype.Component;

/**
 * create by yongli on 2021-06-17 08:56
 * 如果有两个队列监听，会怎么样？
 */

@Component
@ConditionalOnProperty(name = "config.rabbitmq.enable", havingValue = "true")
public class FaultListener2 {

    private static final Logger loger = LoggerFactory.getLogger(FaultListener2.class);

    @RabbitHandler
    @RabbitListener(queues = Topic.HELLO)
    public void test(MaterialOrder msg) {
        loger.info("from2 " + JSON.toJSONString(msg));
    }
}
